home *** CD-ROM | disk | FTP | other *** search
- *******************************************************************************
- * PROGRAM: Search.wfm
- *
- * WRITTEN BY: Borland Samples Group
- *
- * DATE: 1/94
- *
- * UPDATED: 5/95
- *
- * REVISION: $Revision: 1.28 $
- *
- * VERSION: Visual dBASE
- *
- * DESCRIPTION: This form allows setting a filter on the items currently
- * viewed. It allows you to create a combination filter based
- * on the artist, title, price, release date, and media type
- * of the available items from the Musical Methods store.
- *
- * PARAMETERS: None
- *
- * CALLS: Music.cc (for custom pushbuttons)
- * Music.prg (procedure file)
- *
- * USAGE: DO Search.wfm && or
- *
- * local f
- * set procedure to Search.wfm
- * f = new SearchForm()
- * f.ReadModal()
- *******************************************************************************
- #include <Messdlg.h>
- #include "Music.h"
- set talk off
- set ldcheck off
-
- ** END HEADER -- do not remove this line*
- * Generated on 06/19/94
- *
- parameter bModal
- local f
- f = new SEARCHFORM()
- if (bModal)
- f.mdi = .F. && ensure not MDI
- f.ReadModal()
- else
- f.Open()
- endif
- CLASS SEARCHFORM OF FORM
- Set Procedure to Music.cc Additive
- this.MousePointer = 1
- this.ColorNormal = "W"
- this.Width = 60.35
- this.Top = 6.18
- this.Text = "Search"
- this.Left = 23.29
- this.OnSelection = CLASS::ONSELECTION
- this.Height = 8.71
- this.Minimize = .F.
- this.Maximize = .F.
- this.OnOpen = CLASS::ONOPEN
- this.OnClose = CLASS::ONCLOSE
- this.HelpFile = ""
- this.HelpId = ""
-
- DEFINE RECTANGLE SEARCHRECT OF THIS;
- PROPERTY;
- ColorNormal "w*/r",;
- Width 57.97,;
- Top 0.50,;
- Text "",;
- Left 1.19,;
- Height 3.79,;
- Border .T.,;
- BorderStyle 1
-
- DEFINE NORMALTEXT FIELDTEXT OF THIS;
- PROPERTY;
- FontBold .F.,;
- Alignment 5,;
- ColorNormal "w*/r",;
- Width 9.35,;
- Top 1.01,;
- Text "Field:",;
- Left 1.87,;
- Height 1.26,;
- Border .F.
-
- DEFINE COMBOBOX FIELDCOMBO OF THIS;
- PROPERTY;
- Width 27.20,;
- DataSource "STRUCTURE",;
- Top 1.00,;
- ID 800,;
- Left 11.90,;
- Value "",;
- Height 1.18,;
- Style 2,;
- HelpFile "Music.hlp",;
- HelpID "Search Field",;
- StatusMessage "Select a field to search for. Press F1 for Help."
-
- DEFINE NORMALTEXT VALUETEXT OF THIS;
- PROPERTY;
- FontBold .F.,;
- Alignment 5,;
- ColorNormal "w*/r",;
- Width 9.35,;
- Top 2.47,;
- Text "Value:",;
- Left 1.87,;
- Height 1.24,;
- Border .F.
-
- DEFINE NORMALENTRY VALUEENTRY OF THIS;
- PROPERTY;
- ColorNormal "R/W",;
- StatusMessage "Enter a value to search for. Press F1 for help.",;
- Width 45.90,;
- Top 2.47,;
- Left 11.90,;
- Value " ",;
- Height 1.24,;
- HelpFile "Music.hlp",;
- HelpID "Search Value",;
- Border .T.,;
- ColorHighLight "R/W*",;
- Enabled .T.,;
- Function "!"
-
- DEFINE IMAGE LOGOIMAGE OF THIS;
- PROPERTY;
- Alignment 2,;
- Width 10.71,;
- DataSource "FILENAME SMLMUSIC.BMP",;
- Top 4.55,;
- Left 1.19,;
- Height 3.79
-
- DEFINE OKMBUTTON SEARCHOKBUTTON OF THIS;
- PROPERTY;
- Width 14.11,;
- Top 6.50,;
- Left 28.56,;
- Height 1.50
-
- DEFINE CANCELMBUTTON SEARCHCANCELBUTTON OF THIS;
- PROPERTY;
- Group .F.,;
- Width 14.11,;
- Top 6.50,;
- ID 0,;
- Left 44.20,;
- Height 1.50
-
- ****************************************************************************
- procedure OnOpen
- ****************************************************************************
- set procedure to music.prg additive
- form.tempIsOpen = .F. && necessary for knowing if temp
- && table is in use at closing time
- *******************************************************************************
- procedure OnSelection
-
- * Search for the record where searchField = searchValue
- * This procedure is called when the OK button is pressed in the Search form.
- *******************************************************************************
- param controlId
- private curTable,formName,field,value,searchForm,foundRecord,saveFilt,;
- tagNo,keyTagno,closeForm
-
- field = ALLTRIM(this.fieldCombo.value) && searchField
- value = ALLTRIM(this.valueEntry.value) && searchValue
- closeForm = .F.
- saveFilt = setto("filter")
- set filter to
- curTable = alias()
- do case
- case controlId = 0 && Cancel was selected. Don't do anything
- closeForm = .T.
- case empty(field)
- AlertMessage("No field was selected. Try again.","Alert")
- case empty(value)
- AlertMessage("No value was specified. Try again.", "Alert")
- otherwise
- if .not. form.tempIsOpen
- use (curTable) in select() again alias temp
- form.tempIsOpen = .T.
- endif
- select temp
- set filter to &saveFilt && Same filter as main table
- go top
- *** convert value to type of key()
- value = iif(type(field) $ "NF",val(value),value)
- tagNo = tagno(field)
- keyTagNo = key(tagNo)
- * Tags based on single field have field name
- if tagNo > 0 .and. ;
- (keyTagNo = field .or. upper(keyTagNo) = "UPPER(" + field)
- set order to &field
- seek value
- else
- locate for &field = value
- endif
- *** convert back to character type if necessary
- value = ALLTRIM(this.valueEntry.value)
- foundRecord = recno()
- select &curTable
- if .not. found("temp")
- if ConfirmationMessage(FormatStr("%1 %2 not found. Continue Search?",;
- proper(field),value),;
- "Confirmation") = NO
- use in temp
- form.tempIsOpen = .F.
- closeForm = .T.
- endif
- else
- go foundRecord
- set message to FormatStr("%1 %2 was found.", proper(field),value)
- use in temp
- form.tempIsOpen = .F.
- closeForm = .T.
- endif
- endcase
- if closeForm
- form.Close()
- endif
-
- *******************************************************************************
- procedure OnClose
- *******************************************************************************
- if form.tempIsOpen
- use in temp
- endif
-
- ENDCLASS
-
-
-
-